package com.gw.quotes.net.service;

import java.util.List;

import org.ksoap2.serialization.SoapObject;

import android.util.Log;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.gw.quotes.entity.business.Pricelist;
import com.gw.quotes.net.NewException;
import com.gw.quotes.net.Request;
import com.gw.quotes.net.Response;

/**
 * 订单列表 getPricelist
 * 
 * @author Administrator
 *
 */
public class PricelistQueryServiceImpl extends WebBaseServiceImpl {

	@Override
	public Response setResponse() {
		return new Response();
	}
	
	@Override
	public void checkParam(Request request) throws NewException {
		if (request == null) {
			throw new NewException(Response.RESULT_ERROR, "传入request不能为空");
		}
	}

	@Override
	public void setParamByRequest(Request request, SoapObject rpc)
			throws NewException {
		if (request.getGoodsclassguid() == null
				|| request.getGoodsclassguid().trim().equals("")) {
			return;
		}
		//rpc.addProperty("priceguid", request.getPriceguid());
		rpc.addProperty("arg0", request.getGoodsclassguid());
	}

	@Override
	public String getMethodName() throws NewException {
		return "getPricelist";
	}

	@Override
	public void resolveResponse(Object object, Response response)
			throws NewException {
		try {
			Gson gson = new Gson();
			java.lang.reflect.Type type = new TypeToken<List<Pricelist>>() {
			}.getType();
			List<Pricelist> goodsclasses = gson.fromJson(object.toString(),
					type);
			response.setMsg("");
			response.setResult(Response.RESULT_SUCCESS);
			response.setObj(goodsclasses);
		} catch (Exception e) {
			response.setMsg("获取失败");
			response.setResult(Response.RESULT_ERROR);
		}
	}

}
